import React from 'react'


export default class StateForm extends React.Component {


    constructor() {
        super()

        this.state={
            value:'',
            pwd:''
        }
    }
  


    handleSubmit=(e)=>{
        e.preventDefault()

        console.log(this.state.value)
        let {value,pwd}=this.state;

        console.log(value,pwd)

    }

    handleChange1=(e)=>{

   

        this.setState({
            value:e.target.value
        })



    }
    handleChange2=(e) => {
        this.setState({
            pwd:e.target.value
        })

    }


    render() {
        return (
            <div>

                <h3>  StateForm</h3>

                <form onSubmit={this.handleSubmit}>
                    <label>
                        名字:
          <input type="text" value={this.state.value} onChange={this.handleChange1} />
                    </label>

                    <label>
                        密码:
          <input type="password" value={this.state.pwd} onChange={this.handleChange2} />
                    </label>



                    <input type="submit" value="提交" />
                </form>

                <div>{this.state.value}----------{this.state.pwd}</div>
            </div>
        )
    }
}
